/**
 * MineAdmin is committed to providing solutions for quickly building web applications
 * Please view the LICENSE file that was distributed with this source code,
 * For the full copyright and license information.
 * Thank you very much for using MineAdmin.
 *
 * @Author X.Mo<root@imoi.cn>
 * @Link   https://github.com/mineadmin
 */
import type { MaFormItem } from "@mineadmin/form";
import hasAuth from "@/utils/permission/hasAuth.ts";
import MaDictSelect from "@/components/ma-dict-picker/ma-dict-select.vue";
import { concat } from "lodash-es";
import MaDictRadio from "@/components/ma-dict-picker/ma-dict-radio.vue";
export default function getFormItems(
  formType: "add" | "edit" = "add",
  t: any,
  model: any
): MaFormItem[] {
  return concat([
    {
      label: t("commerce_address.fields.user_id"),
      prop: "user_id",
      render: () => MaDictSelect,
      renderProps: { multiple: false },
    },
    {
      label: t("commerce_address.fields.name"),
      prop: "name",
      render: "input",
      renderProps: { placeholder: t("commerce_address.placeholders.name") },
      itemProps: {
        rules: [
          { required: true, message: t("commerce_address.placeholders.name") },
        ],
      },
    },
    {
      label: t("commerce_address.fields.phone"),
      prop: "phone",
      render: "input",
      renderProps: { placeholder: t("commerce_address.placeholders.phone") },
      itemProps: {
        rules: [
          { required: true, message: t("commerce_address.placeholders.phone") },
        ],
      },
    },
    {
      label: t("commerce_address.fields.province"),
      prop: "province",
      render: "input",
      renderProps: { placeholder: t("commerce_address.placeholders.province") },
      itemProps: {
        rules: [
          {
            required: true,
            message: t("commerce_address.placeholders.province"),
          },
        ],
      },
    },
    {
      label: t("commerce_address.fields.city"),
      prop: "city",
      render: "input",
      renderProps: { placeholder: t("commerce_address.placeholders.city") },
      itemProps: {
        rules: [
          { required: true, message: t("commerce_address.placeholders.city") },
        ],
      },
    },
    {
      label: t("commerce_address.fields.district"),
      prop: "district",
      render: "input",
      renderProps: { placeholder: t("commerce_address.placeholders.district") },
      itemProps: {
        rules: [
          {
            required: true,
            message: t("commerce_address.placeholders.district"),
          },
        ],
      },
    },
    {
      label: t("commerce_address.fields.address"),
      prop: "address",
      render: "input",
      renderProps: { placeholder: t("commerce_address.placeholders.address") },
      itemProps: {
        rules: [
          {
            required: true,
            message: t("commerce_address.placeholders.address"),
          },
        ],
      },
    },
    {
      label: t("commerce_address.fields.is_default"),
      prop: "is_default",
      render: () => MaDictRadio,
      renderProps: {
        placeholder: t("commerce_address.placeholders.is_default"),
        data: [
          { label: "是", value: 1, color: "primary" },
          { label: "否", value: 2, color: "danger" },
        ],
      },
    },
  ]);
}
